<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>统计报表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f8f8f8;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
        }
        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 20px;
        }
        .container {
            width: 100%;
            max-width: 800px;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 0 auto;
            border-radius: 8px;
            overflow: hidden;
        }
        th, td {
            text-align: center;
            padding: 12px;
            border: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
            font-weight: bold;
        }

        tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        .link-container {
            width: 100%; /* 宽度与表格一致 */
            text-align: left; /* 左对齐 */
            margin: 20px auto; /* 上下外边距，左右外边距自动 */
            max-width: 800px; /* 与表格的最大宽度一致 */
        }

    </style>
</head>
<body>
    <div class="container">
        <h1>统计报表</h1>
        <table>
            <tr>
                <th>总产品数</th>
                <td>{{ total_products }}</td>
            </tr>
            <tr>
                <th>有库存产品数</th>
                <td>{{ products_with_stock}}</td>
            </tr>
            <tr>
                <th>库存总数量</th>
                <td>{{ total_quantity }}</td>
            </tr>
            <tr>
                <th>总货值</th>
                <td>{{ total_value | round(2) }}元</td>
            </tr>
            <tr>
                <th>总净值</th>
                <td>{{ total_net_value | round(2) }}元</td>
            </tr>
            <tr>
                <th>客户数</th>
                <td>{{ total_customers }}</td>
            </tr>
            <tr>
                <th>客户预存余额汇总</th>
                <td>{{ total_customer_prepaid | round(2) }}元</td>
            </tr>
            <tr>
                <th>供应商数</th>
                <td>{{ total_suppliers }}</td>
            </tr>
            <tr>
                <th>供应商账户余额汇总</th>
                <td>{{ total_supplier_prepaid | round(2) }}元</td>
            </tr>
            <tr>
                <th>库存现金总余额</th>
                <td>{{ total_cash_balance | round(2) }}元</td>
            </tr>
            <tr>
                <th>客户预存现金总余额</th>
                <td>{{ total_predeposit_balance | round(2) }}元</td>
            </tr>
            <tr>
                <th>总现金余额（库存现金 + 客户预存现金）</th>
                <td>{{ total_cash_and_predeposit_balance | round(2) }}元</td>
            </tr>
        </table>
    </div>
    <div class="link-container">
        <a href="{{ url_for('list_products') }}">返回产品列表</a>
        <a href="{{ url_for('index') }}">返回主页</a>
    </div>
</body>
</html>